<?php
/**
 * fldcms
 * ============================================================================
 * 版权所有 2017 福建华晟网络科技，并保留所有权利。
 * 网站地址: http://www.fldcms.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * Author: fld
 * Date: 2017-08-09
 */
namespace app\admin\controller;
use think\Request;
use think\helper\Time;
/**
 * 会员管理
 * @author fld
 *
 */
class MemberController extends BaseController{
	function __construct(){
		parent::__construct();
		$this->db = model('Member');
	}
	/**
	 * 会员列表
	 */
	public function indexOp(){
		$result = $this->getCondition();
		$list = $this->db->getMemberList($result);
		$this->assign("list",$list);
		// 获取分页显示
		$page = $list->render();
		$this->assign('page', $page);
		return $this->fetch();
	}
	
	public function getCondition(){
		$result = array();
		$condition = array();
		$query = array();
		//关键字
		$keyword = input('param.keyword/s');
		if(!empty($keyword)){
			$condition['nick_name'] = array('like','%'.$keyword.'%');
			$query['keyword'] = $keyword;
		}
		$condition['is_del'] = 0;
		$this->assign('keyword',$keyword);
		$result['condition'] = $condition;
		$result['query'] = $query;
		return $result;
	}
	/**
	 * 查看会员信息
	 */
	public function viewOp(){
		//会员信息
		$id = input('param.id');
		$info = $this->db->getInfo(array('id'=>$id));
		$this->assign('vo',$info);
		return $this->fetch();
	}
	/**
	 * 删除会员信息
	 */
	public function deleteOp(){
		$result = array();
		$id = input('param.id');
		$res = $this->db->deleteData(array('id'=>$id));
		if($res !== false){
		    $result['error'] = 0;
		}else{
			$this->msg = "删除会员失败";
			$result['error'] = 1;
		}
		$result['msg'] = $this->msg;
		return json($result);
	}
	
}